# Figure 1

#####
rm(list=ls(all=TRUE))

library("ggpubr")
library("tidyverse")
# ggthemr("fresh")


#### Dataset Original ####
setwd("/Users/sebastian/Dropbox/The politics of interruptions - JOP RR/Replication Files/Data Rep")
load("data_empirics_rep.Rdata")

#### Overlapping interruption histograms

interruption_final <- cbind.data.frame(sum(data_empirics$interruption_final_combined), "All")
colnames(interruption_final) <- c("interruption","Type")
aggressive_final <- cbind.data.frame(sum(data_empirics$aggressive_interruption_combined),"Aggressive")
colnames(aggressive_final) <- c("interruption","Type")
procedural_final <- cbind.data.frame(sum(data_empirics$procedural_interruption_combined),"Procedural")
colnames(procedural_final) <- c("interruption","Type")
other_temp <- interruption_final$interruption[1] - aggressive_final$interruption[1] - procedural_final$interruption[1]
other_final <- cbind.data.frame(other_temp,"Other")
colnames(other_final) <- c("interruption","Type")
interruptions <- rbind.data.frame(interruption_final, procedural_final,aggressive_final, other_final)

### Histogram interruptions:

hist_all <- ggplot(data_empirics, aes(interruption_final_combined)) +
  geom_histogram( binwidth = 1, alpha = 0.9, size = .3, color="black", fill = "gray") +
  xlab("Interruptions") + ylab("Count") +
  scale_x_continuous(breaks=seq(0,20)) +
  coord_cartesian(xlim=c(-.5,8.1)) + 
  theme_minimal()

### Histogram by type:

col_type <- ggplot(interruptions, aes(x=Type,y=interruption)) +
  geom_col(alpha = 0.9, size = .3, color="black", fill = "gray") +
  xlab("Interruption Type") + ylab("Count") +
  theme_minimal()

### Combine:

combined_hist_col <- ggarrange(hist_all, col_type,
                               ncol = 2)

combined_hist_col

### FIGURE 1: Distribution interruptions
setwd("/Users/sebastian/Dropbox/The politics of interruptions - JOP RR/Replication Files/Figures")
ggsave("figure1.pdf", width = 10, height = 8)


